import React from 'react'

export default class Data extends React.Component{
  render() {
    return <div>
      <button onClick={ () => this.getData() }>get请求</button>
      <button onClick={ () => this.postData() }>post请求</button>
    </div>
  }

  // getData = () => {
  //   this.http.get('http://www.liulongbin.top:3005/api/getlunbo')
  //     .then(res=> {
  //       console.log(res.data)
  //     })
  // }
  
  postData = () => {
    this.http.post('http://www.liulongbin.top:3005/api/post', {
      name: 'pang1',
      age: 18
    }).then(res=> {
      console.log(res.data)
    })
  }

  getData = async () => {
    let {data} = await this.http.get('http://www.liulongbin.top:3005/api/getlunbo')
    console.log(data) 
  }
}